'''
Created on May 7, 2011

@author: james
'''

class EvaluatorHelper:
    def __init__(self):
        pass
    
    @staticmethod
    def maxPenalty(total, individuals):
        desiredCount = total / float(individuals)
        return int(desiredCount * ((individuals - 1) * 2))
    
    @staticmethod
    def calculateDistributionPenalty(counts, total, individuals, maxDesiredPenalty):
        
        desiredCount = total / float(individuals)
        maxPenalty = desiredCount * ((individuals - 1) * 2)
        
        penalty = 0
        
        for _, value in counts.items():
            penalty += abs(value - desiredCount)
        
        return int(penalty / maxPenalty * maxDesiredPenalty)
            
    @staticmethod
    def getCallShiftIndex(day, shiftCycle):
        remainder = (day % len(shiftCycle))
        index = (day // len(shiftCycle)) * sum(shiftCycle) + sum(shiftCycle[:remainder])
        return [index, remainder]
